package com.yixin.hospital.controller;

import com.yixin.hospital.common.ApiResult;
import com.yixin.hospital.entity.dto.req.activity.ActivityAddReqDTO;
import com.yixin.hospital.entity.dto.req.activity.ActivityEditReqDTO;
import com.yixin.hospital.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@RestController
@RequestMapping("/activity")
@Api(value = "活动管理", tags = "活动管理")
public class ActivityController {

    @Resource
    private ActivityService activityService;

    @GetMapping("/list")
    @ApiOperation(value = "活动列表")
    public ApiResult list() {
        return ApiResult.success(activityService.list());
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加活动")
    public ApiResult<?> add(@Valid @RequestBody ActivityAddReqDTO activityAddReqDTO, HttpServletRequest request) {
        return activityService.add(activityAddReqDTO, request);
    }

    @PutMapping("/edit")
    @ApiOperation(value = "编辑活动")
    public ApiResult<?> edit(@Valid @RequestBody ActivityEditReqDTO activityEditReqDTO, HttpServletRequest request) {
        return activityService.edit(activityEditReqDTO, request);
    }

    @DeleteMapping("/remove/{id}")
    @ApiOperation(value = "删除活动")
    public ApiResult<?> removeActivity(@PathVariable int id) {
        return activityService.removeActivity(id);
    }

}
